package com.ycy;

import cn.hutool.json.JSONUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class GenericDataListener33 extends AnalysisEventListener<RaInfoV2ForVillageUploadForCommonUploadExcelByName> {

    private List<RaInfoV2ForVillageUploadForCommonUploadExcelByName> dataList = new ArrayList<>();

    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        TreeMap<Integer, String> obj = new TreeMap<>(headMap);
        for (Map.Entry<Integer, String> integerStringEntry : obj.entrySet()) {
            System.out.println(String.format("header -> %s : %s", integerStringEntry.getKey(), integerStringEntry.getValue()));
        }
        System.out.println("==============================");
    }

    @Override
    public void invoke(RaInfoV2ForVillageUploadForCommonUploadExcelByName data, AnalysisContext context) {
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 读取完成后的操作
        System.out.println("所有数据读取完成！");
    }

    public List<RaInfoV2ForVillageUploadForCommonUploadExcelByName> getDataList() {
        return dataList;
    }
}